# PoW的核心共识函数，即如何证明一个区块是合法的。


def proof_of_work(self):
    """
    工作量证明，不断的哈希含有增长随机数的区块,并最终将随机数返回
    Proof of work algorithm
    """
    last_block = self.chain[-1]
    last_block.nonce = 0
    while self.valid_proof(last_block) is False:
        last_block.nonce += 1

    return last_block
